// pages/me/me.js
// 引入模块化
const http = require("../../utils/http");
Page({

  /**
   * 页面的初始数据
   */
  data: {
    banner: [],
    list: [],
    like: [],
    active: [],
    indicatorDots: true,
    indicatoractivecolor:"#4eddf9",
    vertical: false,
    autoplay: true,
    interval: 2000,
    duration: 500,
    circular: true,
    previousmargin: "10px",
    nextmargin:"10px",
    index:1,
    len:0,
    show:true
  },

  onSlideChangeEnd:function(e){
    let that = this;
    that.setData({index:e.detail.current + 1})
  },
  getItem:function(ev){
    console.log(ev);
    const id = ev.currentTarget.dataset.index;
    wx.navigateTo({url:"/pages/item/item?id="+id});
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    // 获取推荐数据
    http.request("product/product/getProductRecommendUser",{desc: false,
      orderBy: "top",
      pageNow: 1,
      pageSize: 20,
      seller_user_id: "4bc4027c645343f09a964b5c2e9f875b"},"post").then(res=>{
        console.log(res);
        this.setData({ list: res.data })
      })
  //  猜你喜欢数据
  http.request("product/product/guessYouLike",{},"get").then(res=>{
    console.log(res);
    this.setData({like:res.data})
  })

  // 轮播图数据
  http.request("product/banner/getBySeller/4bc4027c645343f09a964b5c2e9f875b",{},"get").then(res=>{
    console.log(res.data);
    this.setData({ banner: res.data })
  })

  // 招募活动数据
  http.request("requirement/request/getMatchedProducts",{ desc: false,
    orderBy: "outtime",
    pageSize: 100,
    product_type: 2},"post").then(res=>{
      console.log(res.data.matchedProducts);
      this.setData({active:res.data.matchedProducts});
      this.setData({len:res.data.matchedProducts.length})
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    this.setData({autoplay:true})
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
    console.log("页面隐藏了");
    this.setData({autoplay:false})
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})